package com.qinhai.webcs.config;

import com.qinhai.webcs.interceptor.ImgInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName ImgWebConfig
 * @Deacription
 * @Author qinhai
 * @Date 2021/4/20 10:48
 * @Version 1.0
 **/

@Configuration
public class ImgWebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ImgInterceptor())
                .addPathPatterns("/images/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //E:\java\javaproject\webcs\src\main\resources\static
        String path = "E:\\java\\javaproject\\webcs\\src\\main\\resources\\static\\images\\";
        registry.addResourceHandler("/images/**").addResourceLocations("file:" + path);
    }
}
